package com.zh.test.bean;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Map;
import java.util.TreeMap;

/**
 * yml自动映射属性,要有set/get方法,spring默认就通过set/get赋值
 * yml 子节点父节点缩进没有强制要求,但是所有子节点必须整齐,:后面必须是空格而不是tab
 * yml的编码格式如果是gbk的就不能用中文注释,否则会报错
 * springboot会自动将yml中的配置文件类型转化,map-> linkhashmap  list->Arrarylist 这种用法类似于spring的converter类型转换器,会将http请求中的参数自动转成对应的类型,map/实例/字符
 * */
@Component


public class YmlBean2 {
    @Value("${test.name}")
    public String name;
    public int age;

    public ArrayList<String> l;
    public ArrayList<Map<String,String>> lm;
    public Person p;
    public String[] array;
    public Map<String ,String>m;
    public YmlBean2(){

    }
    public Person getP() {
        return p;
    }

    public void setP(Person p) {
        this.p = p;
    }

    public String[] getArray() {
        return array;
    }

    public void setArray(String[] array) {
        this.array = array;
    }

    public void setM(Map<String, String> m) {
        this.m = m;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Map<String, String> getM() {
        return m;
    }

    public ArrayList<String> getL() {
        return l;
    }

    public void setL(ArrayList<String> l) {
        this.l = l;
    }

    public ArrayList<Map<String, String>> getLm() {
        return lm;
    }

    public void setLm(ArrayList<Map<String, String>> lm) {
        this.lm = lm;
    }

    public static void main(String[] args) {
        TreeMap<Integer,String>m = new TreeMap<>();
        m.put(5,"5");
        m.put(3,"3");
        m.put(4,"4");
                m.put(2,"2");
                m.put(1,"1");
    }
}
